home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
msflex2a
/
grid.frm
< prev
Wrap
Text File
|
1999-09-24
|
16KB
|
505 lines
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form BackGrnd
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "Test Grid"
ClientHeight = 3360
ClientLeft = 45
ClientTop = 360
ClientWidth = 4695
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3360
ScaleWidth = 4695
StartUpPosition = 2 'CenterScreen
Begin VB.CheckBox AutoReturn
Caption = "Auto Return to Col. 1"
Height = 255
Left = 2640
TabIndex = 4
TabStop = 0 'False
Top = 120
Width = 1815
End
Begin VB.CommandButton Stop
Caption = "STOP"
Height = 375
Left = 1920
TabIndex = 2
Top = 2880
Width = 975
End
Begin VB.TextBox T1
Appearance = 0 'Flat
BackColor = &H00C0FFFF&
BorderStyle = 0 'None
Height = 285
Left = 2160
MaxLength = 20
TabIndex = 1
Top = 1200
Visible = 0 'False
Width = 975
End
Begin MSFlexGridLib.MSFlexGrid FG1
Height = 2415
Left = 240
TabIndex = 0
Top = 360
Width = 4215
_ExtentX = 7435
_ExtentY = 4260
_Version = 393216
Rows = 30
Cols = 10
AllowBigSelection= 0 'False
ScrollTrack = -1 'True
FillStyle = 1
End
Begin VB.Label CellIndicator
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 3
Top = 120
UseMnemonic = 0 'False
Width = 105
End
Begin VB.Menu MnuFGridRows
Caption = "Row Popup"
Visible = 0 'False
Begin VB.Menu MnuFGridAddRow
Caption = "Add a Row"
End
Begin VB.Menu MnuFGridInsRow
Caption = "Insert a Row"
End
Begin VB.Menu MnuFGridDelRow
Caption = "Delete a Row"
End
Begin VB.Menu MnuFGridExtrRow
Caption = "Extract a Row"
End
End
Begin VB.Menu MnuFGridCols
Caption = "Col Popup"
Visible = 0 'False
Begin VB.Menu MnuFGridAddCol
Caption = "Add a Col"
End
Begin VB.Menu MnuFGridInsCol
Caption = "Insert a Col"
End
Begin VB.Menu MnuFGridDelCol
Caption = "Delete a Col"
End
Begin VB.Menu MnuFGridExtrCol
Caption = "Extract a Col"
End
End
End
Attribute VB_Name = "BackGrnd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'MSFlexgrid Edit : 9-12-99
'this is an effective and completely natural looking way
'to edit data in the MSFlexgrid object. I've chosen to keep
'all columns the same width that is why I've used .TextMatrix
'in Form_Load() below rather than .Format$.
'If you don't care that numbers and chars wind up aligned
'differently in the columns then remove .ColAlignment(-1)=1
'in the Form_Load() sub.
'Move the cell around with the cursor keys or click with
'the mouse on the destination cell.
'Starting to type will replace the current value in that cell.
'If you wish to edit the existing text in a cell then press F2.
'You can enter a cell, drag the mouse and then start typing and
'VOILA you fill in all the hi-lited cells. The same thing can
'be achieved by pressing the SHIFT & CURSOR keys. (This is also
'an effective way of erasing a whole block of data.)
'<ENTER> key advances to the next cell.
'If you can improve the code...COOL, let me know.
'9-13-99
'Went through the code and eliminated some dead code from
'previous versions as well as some typos.
'Navigtion keys are the usual <Home>, <End>, <Pg Up / Dn>
'along with their Ctrl alternates
'9-14-99
'added a Cell indicator - may come in handy in BIG Grids
'Also added a choice button to autom. return the focus
'to the first column or just go down 1 row
'similar thing can be accomplished like so:
'( in Incr_Cell() )
'
' if Fg1.ColIsVisible(1) then
' FG1.Col=1
' end if
'9-23-99
'added In-Cell cursor control to move to adjacent cells for
'up/dn anytime, right/left when cursor pos is either right
'or leftmost, in cell, respectively. When in the last cell
'(and editing) Right cursor will advance to next row col 1.
'When in the first cell (and editing) Left cursor will jump
'to last cell one row up.
'Typing into a cell with existing data OVERWRITES unless you
'press F2, but if you forget you can now press <ESC> and
'restore the previous value (before exiting the cell).
'also added Popupmenus for Adding, Deleting, Inserting and
'Extracting either Rows or Cols.
'Just put mouse in Col 0 or Row 0 and click Right Mouse Button.
'Add - means add Row at bottom or Col at end
'Delete - means del LAST Row or LAST Col
'Insert - means INSERT a Row / Col at present cursor pos.
'Extract - means EXTRACT a Row /Col at present cursor pos.
'If you try to DELETE / EXTRACT a Row / Col that has data
'in it you will be prompted if you wish to proceed.
'The Popupmenus were created the usual way and then had their
'Titles set to : Visible = False
'
'9-24-99 minor fix to T1_KeyDown.... Case 27, 37-40
'otherwise it adds a char to the text in Case Else!
'Now posted as as .vbp file
'Peter Raddatz - lupo@unix.infoserve.net
Private Sub Form_Load()
Dim y%
With FG1
.ColAlignment(-1) = 1
For y% = 1 To .Cols - 1
.TextMatrix(0, y%) = "Col " + Str(y%)
Next
For y% = 1 To FG1.Rows - 1
.TextMatrix(y%, 0) = "Row " + Str(y%)
Next
.Row = 1
.Col = 1
.CellBackColor = &HC0FFFF 'lt. yellow
BackGrnd.CellIndicator = " " + .TextMatrix(.Row, 0) + " : " + .TextMatrix(0, .Col) + " "
End With
End Sub
Private Sub AutoReturn_Click()
FG1.SetFocus
End Sub
Private Sub FG1_EnterCell()
BackGrnd.CellIndicator = " " + FG1.TextMatrix(FG1.Row, 0) + " : " + FG1.TextMatrix(0, FG1.Col) + " "
T1.Visible = False
FG1.Tag = FG1
FG1.CellBackColor = &HC0FFFF 'lt. yellow
FG1.SetFocus
End Sub
Private Sub FG1_LeaveCell()
FG1.CellBackColor = &H80000005 'white
End Sub
Private Sub FG1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 113 'F2
Set_TextBox
End Select
End Sub
Private Sub FG1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13 'ENTER key
KeyCode = 0
INCR_CELL
Case 8 'BkSpc
FG1 = Left$(FG1, Len(FG1) - 1)
Set_TextBox
Case 27 'Esc - ignore
Case Else
FG1 = Chr$(KeyAscii)
T1 = Chr$(KeyAscii)
Set_TextBox
End Select
End Sub
Private Sub T1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 27 'ESC - OOPS, restore old text
T1 = FG1.Tag
T1.SelStart = Len(T1)
Case 37 'Left Arrow
If T1.SelStart = 0 And FG1.Col > 1 Then
FG1.Col = FG1.Col - 1
Else
If T1.SelStart = 0 And FG1.Row > 1 Then
FG1.Row = FG1.Row - 1
FG1.Col = FG1.Cols - 1
End If
End If
Case 38 '